﻿<%@ Page Language="C#"  MasterPageFile="~/templates/template.Master" AutoEventWireup="true" CodeBehind="empresa.aspx.cs" Inherits="GesWork.maestros.empresa" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxcontroltoolkit" %>


    <asp:content ID="df" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
      
            <ajaxcontroltoolkit:TabContainer ID="tabcont" runat="server"   Width="690px"
    ActiveTabIndex="0">
         <ajaxcontroltoolkit:TabPanel runat="server" ID="tabUser"  HeaderText="Datos"><ContentTemplate>
         
         
      
       <asp:FormView ID="FormView1" runat="server" CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource1" 
            ForeColor="#333333"  
            Width="670px" AllowPaging="True"  >
            <FooterStyle BackColor="#b3b3b3" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#b3b3b3"  /><EditRowStyle  BackColor="#b3b3b3"  ForeColor="White" />
            <EditItemTemplate>
             <div class="recuadro">
                ID:
                <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                
                Name:
                <asp:TextBox ID="NameTextBox" runat="server" 
                    Text='<%# Bind("Name") %>' />
                <br />
                NIF:
                <asp:TextBox ID="NIFTextBox" runat="server" Text='<%# Bind("NIF") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
            <!--      
                <b>Sociedad:</b>
               
                <asp:DropDownList ID="cmbSociedad" runat="server" DataSourceID="dsSociedad"  Text='<%# Bind("CC_IdSociety") %>'
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsSociedad" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [ID], [Description] FROM [Society]">
                </asp:SqlDataSource>
                <br />
                <b>CNAE:</b>
                <asp:DropDownList ID="cmbCNAE" runat="server" DataSourceID="dsCNAE"  Text='<%# Bind("CC_IdCNAE") %>' 
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsCNAE" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [CNAE]"></asp:SqlDataSource>
                <br />
                <b>Sector:</b>
                
                <asp:DropDownList ID="cmbSector" runat="server" DataSourceID="dsSector"  Text='<%# Bind("CC_IdSector") %>'
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsSector" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [Sector]">
                </asp:SqlDataSource>
                <br />
              -->
                 
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                 <b>Zona:</b>
               
                <asp:DropDownList ID="cmbZona" runat="server" DataSourceID="dsZona"   Text='<%# Bind("CC_IdZone") %>'
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsZona" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [Zone]"></asp:SqlDataSource>
                <br />
                
                Telefono 1:
                <asp:TextBox ID="CI_Telephone1TextBox" runat="server" 
                    Text='<%# Bind("CI_Telephone1") %>' />
                <br />
                Telefono 2:
                <asp:TextBox ID="CI_Telephone2TextBox" runat="server" 
                    Text='<%# Bind("CI_Telephone2") %>' />
                <br />
                Telefono 3:
                <asp:TextBox ID="CI_Telephone3TextBox" runat="server" 
                    Text='<%# Bind("CI_Telephone3") %>' />
                <br />
                Fax:
                <asp:TextBox ID="CI_FaxTextBox" runat="server" 
                    Text='<%# Bind("CI_Fax") %>' />
                <br />
                Email 1:
                <asp:TextBox ID="CI_Email1TextBox" runat="server" 
                    Text='<%# Bind("CI_Email1") %>' />
                <br />
                Email 2:
                <asp:TextBox ID="CI_Email2TextBox" runat="server" 
                    Text='<%# Bind("CI_Email2") %>' />
                <br />
                Email 3:
                <asp:TextBox ID="CI_Email3TextBox" runat="server" 
                    Text='<%# Bind("CI_Email3") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                Responsable:
                <asp:TextBox ID="IdOwnerUserTextBox" runat="server" 
                    Text='<%# Bind("IdOwnerUser") %>'  Enabled="false"/>
                <br />
<!--                Imagen:
                <asp:TextBox ID="IMG_ImageTextBox" runat="server" 
                    Text='<%# Bind("IMG_Image") %>' />
      -->        
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                <b>Relacion:</b>
                
                <asp:DropDownList ID="cmbRelacion" runat="server" DataSourceID="dsRelacion" Text='<%# Bind("CC_IdRelationShip") %>'
                    DataTextField="description" DataValueField="id">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsRelacion" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [id], [description] FROM [Relations]">
                </asp:SqlDataSource>
                <br />
                <b>Categoria:</b>
                
                <asp:DropDownList ID="cmbCategoria" runat="server" DataSourceID="dsCategoria"  Text='<%# Bind("CC_IdCategory") %>' 
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsCategoria" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [ID], [Description] FROM [ContactCategory]">
                </asp:SqlDataSource>
                <br />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                
<asp:ImageButton ID="UpdateButton" runat="server"  ImageUrl="~/images/btnGuardar.png"  CssClass="botones" CausesValidation="True" 
                    CommandName="Update"  />
               
<asp:ImageButton ID="UpdateCancelButton" runat="server"  ImageUrl="~/images/btnCancelar.png"  CssClass="botones" 
                    CausesValidation="False" CommandName="Cancel" />
                    
               </div>
            </EditItemTemplate>
            <InsertItemTemplate>
              <div class="recuadro">
                Nombre:
                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
                <br />
                NIF:
                <asp:TextBox ID="NIFTextBox" runat="server" 
                    Text='<%# Bind("NIF") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                
             <!--    <b>Sociedad:</b>
               
                <asp:DropDownList ID="cmbSociedad" runat="server" DataSourceID="dsSociedad"  Text='<%# Bind("CC_IdSociety") %>'
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsSociedad" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [ID], [Description] FROM [Society]">
                </asp:SqlDataSource>
                <br />
               <b>CNAE:</b>
                <asp:DropDownList ID="cmbCNAE" runat="server" DataSourceID="dsCNAE"  Text='<%# Bind("CC_IdCNAE") %>' 
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsCNAE" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [CNAE]"></asp:SqlDataSource>
                <br />
                <b>Sector:</b>
                
                <asp:DropDownList ID="cmbSector" runat="server" DataSourceID="dsSector"  Text='<%# Bind("CC_IdSector") %>'
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsSector" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [Sector]">
                </asp:SqlDataSource>
                <br />
             -->   
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                
                <b>Zona:</b>
               
                <asp:DropDownList ID="cmbZona" runat="server" DataSourceID="dsZona"   Text='<%# Bind("CC_IdZone") %>'
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsZona" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [Zone]"></asp:SqlDataSource>
                <br />
                
                
                Telefono 1:
                <asp:TextBox ID="CI_Telephone1TextBox" runat="server" 
                    Text='<%# Bind("CI_Telephone1") %>' />
                <br />
                Telefono 2:
                <asp:TextBox ID="CI_Telephone2TextBox" runat="server" 
                    Text='<%# Bind("CI_Telephone2") %>' />
                <br />
                Telefono 3 :
                <asp:TextBox ID="CI_Telephone3TextBox" runat="server" 
                    Text='<%# Bind("CI_Telephone3") %>' />
                <br />
                Fax:
                <asp:TextBox ID="CI_FaxTextBox" runat="server" 
                    Text='<%# Bind("CI_Fax") %>' />
                <br />
                Email 1:
                <asp:TextBox ID="CI_Email1TextBox" runat="server" 
                    Text='<%# Bind("CI_Email1") %>' />
                <br />
                Email 2:
                <asp:TextBox ID="CI_Email2TextBox" runat="server" 
                    Text='<%# Bind("CI_Email2") %>' />
                <br />
                Email 3:
                <asp:TextBox ID="CI_Email3TextBox" runat="server" 
                    Text='<%# Bind("CI_Email3") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                Responsable:
                <asp:TextBox ID="IdOwnerUserTextBox" runat="server" Enabled="false"
                    Text='<%# Bind("IdOwnerUser") %>' />
                <br />
 <!--                Imagen:
                <asp:TextBox ID="IMG_ImageTextBox" runat="server" 
                    Text='<%# Bind("IMG_Image") %>' />
                <br />
    -->            
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                <b>Relacion:</b>
                
                <asp:DropDownList ID="cmbRelacion" runat="server" DataSourceID="dsRelacion" Text='<%# Bind("CC_IdRelationShip") %>'
                    DataTextField="description" DataValueField="id">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsRelacion" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [id], [description] FROM [Relations]">
                </asp:SqlDataSource>
                <br />
                <b>Categoria:</b>
                
                <asp:DropDownList ID="cmbCategoria" runat="server" DataSourceID="dsCategoria"  Text='<%# Bind("CC_IdCategory") %>' 
                    DataTextField="Description" DataValueField="ID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsCategoria" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [ID], [Description] FROM [ContactCategory]">
                </asp:SqlDataSource>
                <br />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                
                
<asp:ImageButton ID="InsertButton" runat="server"  ImageUrl="~/images/btnGuardar.png"  CssClass="botones" CausesValidation="True" 
                    CommandName="Insert" Text="Insertar" />
               
<asp:ImageButton ID="InsertCancelButton" runat="server"  ImageUrl="~/images/btnCancelar.png"  CssClass="botones" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
              </div>
            </InsertItemTemplate>
            <ItemTemplate>
           
                 <div class="separador"></div> 
                <!--  <br />
                <b>ID:</b> -->
                <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' Visible="false"/>
               
               
                 <br />
                <b>Nombre:</b>
                <asp:Label ID="NameLabel" runat="server" 
                    Text='<%# Eval("Name") %>' />
                <br />
                <b>NIF:</b>
                <asp:Label ID="NIFLabel" runat="server" Text='<%# Eval("NIF") %>' />
               
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
        <!--         <b>Sociedad:</b>
                <asp:Label ID="sociedadLabel" runat="server" Text='<%# Eval("sociedad") %>' />
                <br />
                <b>CNAE:</b>
                <asp:Label ID="cnaeLabel" runat="server" 
                    Text='<%# Eval("cnae") %>' />
                <br />
                <b>Sector:</b>
                <asp:Label ID="sectorLabel" runat="server" 
                    Text='<%# Bind("sector") %>' />
                
                
              <br /><br /> 
                 <div class="separador"></div> 
                 <br />
             -->      
                
                 <b>Zona:</b>
                <asp:Label ID="zonaLabel" runat="server" 
                    Text='<%# Bind("zona") %>' />
               
               <br />
                <b>Telefono:</b>
                <asp:Label ID="CI_Telephone1Label" runat="server" 
                    Text='<%# Eval("CI_Telephone1") +" "+ Eval("CI_Telephone2") +" "+ Eval("CI_Telephone3")%>' />
                <br />
                
                <b>Fax:</b>
                <asp:Label ID="CI_FaxLabel" runat="server" 
                    Text='<%# Eval("CI_Fax") %>' />
                <br />
                <b>Email:</b>
                <asp:Label ID="CI_Email1Label" runat="server" 
                    Text='<%# Eval("CI_Email1")+" "+Eval("CI_Email2")+" "+ Eval("CI_Email3")%>' />
                
                
               
               <br /><br /> 
                 <div class="separador"></div> 
                 <br />
               
                <b>Responsable:</b>
                <asp:Label ID="IdOwnerUserLabel" runat="server" 
                    Text='<%# Eval("IdOwnerUser") %>' />
                <br />
 <!--                <b>Imagen:</b>
                <asp:Label ID="IMG_ImageLabel" runat="server" 
                    Text='<%# Eval("IMG_Image") %>' />
               
               <br /><br /> 
          -->        <br />
               <div class="separador"></div> 
                 <br />
                 
                <b>Relacion:</b>
                <asp:Label ID="relacionLabel" runat="server" 
                    Text='<%# Bind("relacion") %>' />
                <br />
                <b>Categoria:</b>
                <asp:Label ID="categoriaLabel" runat="server" 
                    Text='<%# Bind("categoria") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
               
                
                
<asp:ImageButton ID="EditButton" runat="server"  ImageUrl="~/images/btnEditar.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="Edit"  />

 <asp:ImageButton ID="DeleteButton" runat="server"  ImageUrl="~/images/btnEliminar.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="Delete"  />

<asp:ImageButton ID="NewButton" runat="server"  ImageUrl="~/images/btnNuevo.png"  CssClass="botones" CausesValidation="False" CommandName="New" 
                     />
            </ItemTemplate>
            <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#000000" Font-Bold="True" ForeColor="White" />
        </asp:FormView>
         
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
        
            SelectCommand="SELECT Enterprise.ID, Enterprise.Name, Enterprise.NIF, Enterprise.CI_Telephone1, Enterprise.CI_Telephone2, 
Enterprise.CI_Telephone3, Enterprise.CI_Fax, Enterprise.CI_Email1,Enterprise.CI_Email2, Enterprise.CI_Email3, 
Enterprise.IdOwnerUser, Enterprise.IMG_Image, Enterprise.CC_IdRelationShip,relations.description as relacion, 
 Enterprise.CC_IdCategory, contactCategory.description as categoria,  Enterprise.CC_IdSector, Sector.Description AS sector, 
Enterprise.CC_IdZone, Zone.Description AS zona, Enterprise.CC_IdSociety, Society.Description as sociedad, Enterprise.CC_IdCNAE, CNAE.Description as cnae

FROM [Enterprise], relations, contactCategory, Sector, Zone, Society, CNAE 

WHERE  relations.id = CC_IdRelationShip AND contactCategory.id=CC_IdCategory AND Sector.id=CC_IdSector AND Zone.id=CC_IdZone 
AND Society.id=CC_IdSociety AND CNAE.id=CC_IdCNAE
AND Enterprise.ID = @ID" 
            DeleteCommand="DELETE FROM [Enterprise] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [Enterprise] ([Name], [NIF], [CI_Email1], [CI_Email2],   [CI_Email3], [CI_Telephone1], [CI_Telephone2], [CI_Telephone3], [CI_Fax],[CI_Web], 
            [CC_IdRelationShip], [CC_IdCategory], [CC_IdSector], [CC_IdZone], [CC_IdSociety], [CC_IdCNAE], [IdOwnerUser], [IMG_Image], [IdEnterprise]) 
            VALUES (@Name, @NIF,  @CI_Email1, @CI_Email2, @CI_Email3, @CI_Telephone1, @CI_Telephone2, @CI_Telephone3, @CI_Fax, @CI_Web,  
            @CC_IdRelationShip,@CC_IdCategory,@CC_IdSector, @CC_IdZone, @CC_IdSociety, @CC_IdCNAE, @IdOwnerUser, @IMG_Image, @IdEnterprise)" 
            
            UpdateCommand="UPDATE [Enterprise] SET [Name] = @Name, [NIF] = @NIF, [CI_Email1] = @CI_Email1, [CI_Email2] = @CI_Email2, [CI_Email3] = @CI_Email3,  
            [CI_Telephone1] = @CI_Telephone1, [CI_Telephone2] = @CI_Telephone2, [CI_Telephone3] = @CI_Telephone3, [CI_Fax] = @CI_Fax,  [CI_Web] = @CI_Web, 
            
            [CC_IdRelationShip] = @CC_IdRelationShip,[CC_IdCategory] = @CC_IdCategory, [CC_IdSector] = @CC_IdSector, [CC_IdZone] = @CC_IdZone, [CC_IdSociety] = @CC_IdSociety, 
            [CC_IdCNAE] = @CC_IdCNAE, [IdOwnerUser] = @IdOwnerUser, [IMG_Image] = @IMG_Image, [IdEnterprise] = @IdEnterprise WHERE [ID] = @ID">
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="id" Type="Int32" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="NIF" Type="String" />
            <asp:Parameter Name="CI_Email1" Type="String" />
            <asp:Parameter Name="CI_Email2" Type="String" />
            <asp:Parameter Name="CI_Email3" Type="String" />
            <asp:Parameter Name="CI_Telephone1" Type="String" />
            <asp:Parameter Name="CI_Telephone2" Type="String" />
            <asp:Parameter Name="CI_Telephone3" Type="String" />
            <asp:Parameter Name="CI_Fax" Type="String" />
            <asp:Parameter Name="CI_Web" Type="String" />
            <asp:Parameter Name="CC_IdRelationShip" Type="String" />
            <asp:Parameter Name="CC_IdCategory" Type="String" />
            <asp:Parameter Name="CC_IdSector" Type="String" />
            <asp:Parameter Name="CC_IdZone" Type="String" />
            <asp:Parameter Name="CC_IdSociety" Type="String" />
            <asp:Parameter Name="CC_IdCNAE" Type="String" />
            <asp:Parameter Name="IdOwnerUser" Type="String" />
            <asp:Parameter Name="IMG_Image" Type="String" />
            <asp:Parameter Name="IdEnterprise" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="NIF" Type="String" />
            <asp:Parameter Name="CI_Email1" Type="String" />
            <asp:Parameter Name="CI_Email2" Type="String" />
            <asp:Parameter Name="CI_Email3" Type="String" />
            <asp:Parameter Name="CI_Telephone1" Type="String" />
            <asp:Parameter Name="CI_Telephone2" Type="String" />
            <asp:Parameter Name="CI_Telephone3" Type="String" />
            <asp:Parameter Name="CI_Fax" Type="String" />
            <asp:Parameter Name="CI_Web" Type="String" />
            <asp:Parameter Name="CC_IdRelationShip" Type="String" />
            <asp:Parameter Name="CC_IdCategory" Type="String" />
            <asp:Parameter Name="CC_IdSector" Type="String" />
            <asp:Parameter Name="CC_IdZone" Type="String" />
            <asp:Parameter Name="CC_IdSociety" Type="String" />
            <asp:Parameter Name="CC_IdCNAE" Type="String" />
            <asp:Parameter Name="IdOwnerUser" Type="String" />
            <asp:Parameter Name="IMG_Image" Type="String" />
            <asp:Parameter Name="IdEnterprise" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    
      <br />
</p>
<p>
</p>

  </ContentTemplate>
</ajaxcontroltoolkit:TabPanel>

<ajaxcontroltoolkit:TabPanel runat="server" ID="pnlAdress"  HeaderText="Direccion">
    <ContentTemplate>
    
    
   <asp:FormView ID="fvAdress" runat="server" CellPadding="4" DataKeyNames="ID" DataSourceID="dsAddress" 
            ForeColor="#333333"  
            Width="670px" AllowPaging="True"  >
            <FooterStyle BackColor="#b3b3b3" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#b3b3b3"  /><EditRowStyle  BackColor="#b3b3b3"  ForeColor="White" />
            <EditItemTemplate>

<!--
             ID:
                <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
              <br />
          OwnedByID:
                <asp:TextBox ID="OwnedByIDTextBox" runat="server" 
                    Text='<%# Bind("OwnedByID") %>' />
                <br />
                OwnedByType:
                <asp:TextBox ID="OwnedByTypeTextBox" runat="server" 
                    Text='<%# Bind("OwnedByType") %>' />
                <br />
         -->
                <div class="separador"></div> 
                <br />
                
               
               <b> Tipo de direccion:</b>
                <asp:DropDownList ID="IdAddressTypeTextBox" runat="server" DataSourceID="dsTypeAddress" DataTextField="Description" 
                    DataValueField="ID"  
                    Text='<%# Bind("IdAddressType") %>' />
                     <asp:SqlDataSource ID="dsTypeAddress" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [AddressType]">
                </asp:SqlDataSource>
                <br />
                Direccion:
                <asp:TextBox ID="AI_StreetTextBox" runat="server" 
                    Text='<%# Bind("AI_Street") %>' />
                <br />
                Codigo Postal:
                <asp:TextBox ID="AI_PostalCodeTextBox" runat="server" 
                    Text='<%# Bind("AI_PostalCode") %>' />
                <br />
                
                Region:
                <asp:TextBox ID="AI_RegionTextBox" runat="server" 
                    Text='<%# Bind("AI_Region") %>' />
                <br />
                
                Provincia:
                <asp:TextBox ID="AI_ProvinceTextBox" runat="server" 
                    Text='<%# Bind("AI_Province") %>' />
                <br />
                Pais:
                <asp:TextBox ID="AI_CountryTextBox" runat="server" 
                    Text='<%# Bind("AI_Country") %>' />
                <br /><br />
                  <div class="separador"></div> 
                <br />
                 Notas:<br />
                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'  TextMode="MultiLine" Height="100px" Width="600px" />
               
                <br /><br />
                  <div class="separador"></div> 
                <br />
<!--                
                SHI_AI_Street:
                <asp:TextBox ID="SHI_AI_StreetTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_Street") %>' />
                <br />
                SHI_AI_Region:
                <asp:TextBox ID="SHI_AI_RegionTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_Region") %>' />
                <br />
                SHI_AI_PostalCode:
                <asp:TextBox ID="SHI_AI_PostalCodeTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_PostalCode") %>' />
                <br />
                SHI_AI_Province:
                <asp:TextBox ID="SHI_AI_ProvinceTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_Province") %>' />
                <br />
                SHI_AI_Country:
                <asp:TextBox ID="SHI_AI_CountryTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_Country") %>' />
                <br />
                SHI_IdShippingMethod:
                <asp:TextBox ID="SHI_IdShippingMethodTextBox" runat="server" 
                    Text='<%# Bind("SHI_IdShippingMethod") %>' />
                <br />
                SHI_IdFreightTerms:
                <asp:TextBox ID="SHI_IdFreightTermsTextBox" runat="server" 
                    Text='<%# Bind("SHI_IdFreightTerms") %>' />
                <br />
              -->  
<asp:ImageButton ID="UpdateButton" runat="server"  ImageUrl="~/images/btnGuardar.png"  CssClass="botones" CausesValidation="True" 
                    CommandName="Update" Text="Actualizar" />
               
<asp:ImageButton ID="UpdateCancelButton" runat="server"  ImageUrl="~/images/btnCancelar.png"  CssClass="botones" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
                                     
            </EditItemTemplate>
            <InsertItemTemplate>
         <!--       ID:
                <asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>' />
                <br />
       
        
                OwnedByID:
                <asp:TextBox ID="OwnedByIDTextBox" runat="server" 
                    Text='<%# Bind("OwnedByID") %>' />
                <br />
                OwnedByType:
                <asp:TextBox ID="OwnedByTypeTextBox" runat="server" 
                    Text='<%# Bind("OwnedByType") %>' />
                <br />
                  <div class="separador"></div> 
                 <br />
                 
       -->         
                 <div class="separador"></div> 
                <br />
             
                
                
                <b>Tipo de direccion:</b>
                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="dsTypeAddress" DataTextField="Description" 
                    DataValueField="ID"  
                    Text='<%# Bind("IdAddressType") %>' />
                     <asp:SqlDataSource ID="dsTypeAddress" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [AddressType]">
                </asp:SqlDataSource>
                
                <br />
                <b>Direccion:</b>
                <asp:TextBox ID="AI_StreetTextBox" runat="server" 
                    Text='<%# Bind("AI_Street") %>' />
                <br />
                <b>Codigo Postal:</b>
                <asp:TextBox ID="AI_PostalCodeTextBox" runat="server" 
                    Text='<%# Bind("AI_PostalCode") %>' />
                <br />
                
                <b>Localidad:</b>
                <asp:TextBox ID="AI_RegionTextBox" runat="server" 
                    Text='<%# Bind("AI_Region") %>' />
                <br />
                
                <b>Provincia:</b>
                <asp:TextBox ID="AI_ProvinceTextBox" runat="server" 
                    Text='<%# Bind("AI_Province") %>' />
                <br />
                <b>Pais:</b>
                <asp:TextBox ID="AI_CountryTextBox" runat="server" 
                    Text='<%# Bind("AI_Country") %>' />
                <br />
                
  <!--               SHI_AI_Street:
                <asp:TextBox ID="SHI_AI_StreetTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_Street") %>' />
                <br />
                SHI_AI_Region:
                <asp:TextBox ID="SHI_AI_RegionTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_Region") %>' />
                <br />
                SHI_AI_PostalCode:
                <asp:TextBox ID="SHI_AI_PostalCodeTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_PostalCode") %>' />
                <br />
                SHI_AI_Province:
                <asp:TextBox ID="SHI_AI_ProvinceTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_Province") %>' />
                <br />
                SHI_AI_Country:
                <asp:TextBox ID="SHI_AI_CountryTextBox" runat="server" 
                    Text='<%# Bind("SHI_AI_Country") %>' />
                <br />
                SHI_IdShippingMethod:
                <asp:TextBox ID="SHI_IdShippingMethodTextBox" runat="server" 
                    Text='<%# Bind("SHI_IdShippingMethod") %>' />
                <br />
                SHI_IdFreightTerms:
                <asp:TextBox ID="SHI_IdFreightTermsTextBox" runat="server" 
                    Text='<%# Bind("SHI_IdFreightTerms") %>' />
          -->     <br />
       
          <div class="separador"></div> 
                 <br />
                 <b>Notas:</b><br />
                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'  TextMode="MultiLine" Height="100px" Width="600px" />
                
                <br /><br />
                 <div class="separador"></div> 
                <br />
                
<asp:ImageButton ID="InsertButton" runat="server"  ImageUrl="~/images/btnGuardar.png"  CssClass="botones" CausesValidation="True" 
                    CommandName="Insert" Text="Insertar" />
               
<asp:ImageButton ID="InsertCancelButton" runat="server"  ImageUrl="~/images/btnCancelar.png"  CssClass="botones" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
            </InsertItemTemplate>
            <ItemTemplate>
        <!--         ID:
                <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
                <br />
                OwnedByID:
                <asp:Label ID="OwnedByIDLabel" runat="server" Text='<%# Bind("OwnedByID") %>' />
                <br />
                OwnedByType:
                <asp:Label ID="OwnedByTypeLabel" runat="server" 
                    Text='<%# Bind("OwnedByType") %>' />
                <br />
        -->     
                 <div class="separador"></div> 
                 <br />
                
                
                <b>Tipo:</b>
                <asp:Label ID="IdAddressTypeLabel" runat="server" 
                    Text='<%# Bind("AddressType") %>' />
                <br />
                <b>Direccion:</b>
                <asp:Label ID="AI_StreetLabel" runat="server" Text='<%# Bind("AI_Street") %>' />
                <br />
                <b>Codigo Postal:</b>
                <asp:Label ID="AI_PostalCodeLabel" runat="server" 
                    Text='<%# Bind("AI_PostalCode") %>' />
                <br />
                
                <b>Localidad:</b>
                <asp:Label ID="AI_RegionLabel" runat="server" Text='<%# Bind("AI_Region") %>' />
                <br />
                
                <b>Provincia:</b>
                <asp:Label ID="AI_ProvinceLabel" runat="server" 
                    Text='<%# Bind("AI_Province") %>' />
                <br />
                <b>Pais:</b>
                <asp:Label ID="AI_CountryLabel" runat="server" 
                    Text='<%# Bind("AI_Country") %>' />
               
               
               <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                <b>Notas:</b>
                <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                
         <!--       SHI_AI_Street:
                <asp:Label ID="SHI_AI_StreetLabel" runat="server" 
                    Text='<%# Bind("SHI_AI_Street") %>' />
                <br />
                SHI_AI_Region:
                <asp:Label ID="SHI_AI_RegionLabel" runat="server" 
                    Text='<%# Bind("SHI_AI_Region") %>' />
                <br />
                SHI_AI_PostalCode:
                <asp:Label ID="SHI_AI_PostalCodeLabel" runat="server" 
                    Text='<%# Bind("SHI_AI_PostalCode") %>' />
                <br />
                SHI_AI_Province:
                <asp:Label ID="SHI_AI_ProvinceLabel" runat="server" 
                    Text='<%# Bind("SHI_AI_Province") %>' />
                <br />
                SHI_AI_Country:
                <asp:Label ID="SHI_AI_CountryLabel" runat="server" 
                    Text='<%# Bind("SHI_AI_Country") %>' />
                <br />
                SHI_IdShippingMethod:
                <asp:Label ID="SHI_IdShippingMethodLabel" runat="server" 
                    Text='<%# Bind("SHI_IdShippingMethod") %>' />
                <br />
                SHI_IdFreightTerms:
                <asp:Label ID="SHI_IdFreightTermsLabel" runat="server" 
                    Text='<%# Bind("SHI_IdFreightTerms") %>' />
                <br />
          --> 
          
                     <asp:ImageButton ID="EditButton" runat="server"  ImageUrl="~/images/btnEditar.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="Edit" Text="Editar" />
                    
                    
               
<asp:ImageButton ID="DeleteButton" runat="server"  ImageUrl="~/images/btnEliminar.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="Delete" Text="Eliminar" />
                
<asp:ImageButton ID="NewButton" runat="server"  ImageUrl="~/images/btnNuevo.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="New" Text="Nuevo" />
          
          
               
            
            </ItemTemplate>
        </asp:FormView>
    
    
   
        <asp:SqlDataSource ID="dsAddress" runat="server" 
            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
            DeleteCommand="DELETE FROM [Address] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [Address] ( [OwnedByID], [OwnedByType], [Name], [IdAddressType], [AI_Street], [AI_Region], [AI_PostalCode], [AI_Province], [AI_Country], [SHI_AI_Street], [SHI_AI_Region], [SHI_AI_PostalCode], [SHI_AI_Province], [SHI_AI_Country], [SHI_IdShippingMethod], [SHI_IdFreightTerms]) VALUES ( @OwnedByID, '1', @Name, @IdAddressType, @AI_Street, @AI_Region, @AI_PostalCode, @AI_Province, @AI_Country, @SHI_AI_Street, @SHI_AI_Region, @SHI_AI_PostalCode, @SHI_AI_Province, @SHI_AI_Country, @SHI_IdShippingMethod, @SHI_IdFreightTerms)" 
            SelectCommand="SELECT Address.ID, [OwnedByID], [OwnedByType], [Name], [IdAddressType],AddressType.description As AddressType, [AI_Street], [AI_Region], 
                            [AI_PostalCode], [AI_Province], [AI_Country], [SHI_AI_Street], [SHI_AI_Region], [SHI_AI_PostalCode], 
                            [SHI_AI_Province], [SHI_AI_Country], [SHI_IdShippingMethod], [SHI_IdFreightTerms] 

                            FROM [Address], AddressType

                            WHERE ((Address.idAddressType = AddressType.id) AND(Address.OwnedByType = 1) AND (Address.OwnedByID =  @OwnedByID))" 
            UpdateCommand="UPDATE [Address] SET [Name] = @Name, [IdAddressType] = @IdAddressType, [AI_Street] = @AI_Street, [AI_Region] = @AI_Region, [AI_PostalCode] = @AI_PostalCode, [AI_Province] = @AI_Province, [AI_Country] = @AI_Country, [SHI_AI_Street] = @SHI_AI_Street, [SHI_AI_Region] = @SHI_AI_Region, [SHI_AI_PostalCode] = @SHI_AI_PostalCode, [SHI_AI_Province] = @SHI_AI_Province, [SHI_AI_Country] = @SHI_AI_Country, [SHI_IdShippingMethod] = @SHI_IdShippingMethod, [SHI_IdFreightTerms] = @SHI_IdFreightTerms WHERE [ID] = @ID">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="OwnedByType" Type="Int32" />
                <asp:QueryStringParameter Name="OwnedByID" QueryStringField="id" 
                    Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="OwnedByID" Type="String" />
                <asp:Parameter Name="OwnedByType" Type="Int32" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="IdAddressType" Type="Int32" />
                <asp:Parameter Name="AI_Street" Type="String" />
                <asp:Parameter Name="AI_Region" Type="String" />
                <asp:Parameter Name="AI_PostalCode" Type="String" />
                <asp:Parameter Name="AI_Province" Type="String" />
                <asp:Parameter Name="AI_Country" Type="String" />
                <asp:Parameter Name="SHI_AI_Street" Type="String" />
                <asp:Parameter Name="SHI_AI_Region" Type="String" />
                <asp:Parameter Name="SHI_AI_PostalCode" Type="String" />
                <asp:Parameter Name="SHI_AI_Province" Type="String" />
                <asp:Parameter Name="SHI_AI_Country" Type="String" />
                <asp:Parameter Name="SHI_IdShippingMethod" Type="String" />
                <asp:Parameter Name="SHI_IdFreightTerms" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:QueryStringParameter Name="OwnedByID"  QueryStringField="id"  Type="String" />
                <asp:Parameter Name="OwnedByType" Type="Int32" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="IdAddressType" Type="Int32" />
                <asp:Parameter Name="AI_Street" Type="String" />
                <asp:Parameter Name="AI_Region" Type="String" />
                <asp:Parameter Name="AI_PostalCode" Type="String" />
                <asp:Parameter Name="AI_Province" Type="String" />
                <asp:Parameter Name="AI_Country" Type="String" />
                <asp:Parameter Name="SHI_AI_Street" Type="String" />
                <asp:Parameter Name="SHI_AI_Region" Type="String" />
                <asp:Parameter Name="SHI_AI_PostalCode" Type="String" />
                <asp:Parameter Name="SHI_AI_Province" Type="String" />
                <asp:Parameter Name="SHI_AI_Country" Type="String" />
                <asp:Parameter Name="SHI_IdShippingMethod" Type="String" />
                <asp:Parameter Name="SHI_IdFreightTerms" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    
    
    <asp:ImageButton ID="btnNewAddres" runat="server"  ImageUrl="~/images/btnNuevo.png"  CssClass="botones"  OnClick="nuevaDireccion" 
                    Text="Nuevo" Visible="false" />
    
    </ContentTemplate>
</ajaxcontroltoolkit:TabPanel>

<ajaxcontroltoolkit:TabPanel runat="server" ID="pnlContact"  HeaderText="Contactos"><ContentTemplate>
   
   
                                                   <table class="tblGeneral"  style="width:670px">
                                                        <tr class="tblHeader">
                                                               
                                                                <td>
                                                                <b>Nombre</b>
                                                                </td>
                                                                <td>
                                                                <b>Cargo</b>
                                                                </td>
                                                                
                                                                <td>
                                                                <b>Email</b>
                                                                </td>
                                                                
                                                                <td>
                                                                <b>Telefono</b>
                                                                </td>

                                                            </tr>
  <asp:Repeater ID="rptEmpleados" runat="server" DataSourceID="dsEmpleados" >
   <ItemTemplate>
   
   <tr>
                                                               
                                                                <td>
                                                                    <a href='<%# "contacto.aspx?id=" + Eval("ID") %>'  > <%# Eval("name")%>     <%# Eval("firstname")%>     <%# Eval("lastname")%> </a>
                                                                </td>
                                                                <td>
                                                                  <%# Eval("post")%> 
                                                                </td>
                                                                
                                                                <td>
                                                                <a href='<%# "mailto:"+ Eval("CI_email1")%>'><%# Eval("CI_email1")%></a>
                                                                </td>
                                                               
                                                                <td>
                                                                <%# Eval("CI_Telephone1")%>
                                                                </td>

                                                            </tr>

    
   
                    
   </ItemTemplate>
   </asp:Repeater>
   </table>
   <br /><br />
    <asp:ImageButton ID="NewButton" runat="server"  ImageUrl="~/images/btnNuevo.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="New" Text="Nuevo"  PostBackUrl="~/maestros/contacto.aspx"/>
                    
   <asp:SqlDataSource ID="dsEmpleados" runat="server" 
        ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
        
                SelectCommand="SELECT  id, saludation, Contact.name, firstname, lastname, post, CI_email1, CI_Telephone1, identerprise

                                    FROM Contact 

                                    WHERE identerprise =  @ID">
            <SelectParameters>
                <asp:QueryStringParameter Name="ID" QueryStringField="id" Type="Int32" />
            </SelectParameters>
    </asp:SqlDataSource>
   
    </ContentTemplate>
</ajaxcontroltoolkit:TabPanel>
</ajaxcontroltoolkit:TabContainer>
         
  
    </asp:content>

